Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose non-impl-Trait iterator return types #1719

Merged
merged 4 commits into from
Aug 11, 2024
Merged

Expose non-impl-Trait iterator return types #1719

merged 4 commits into from
Aug 11, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Aug 11, 2024

Fixes #1718.

There is no syntax in impl Trait<'a> to express that the underlying type either does not have a Drop impl or has a dropck eyepatch: unsafe impl<#[may_dangle] 'a> Drop.

    error[E0502]: cannot borrow `generics.params` as mutable because it is also borrowed as immutable
      --> tests/test_iterators.rs:81:25
       |
    77 |       let _ = generics
       |               --------
       |               |
       |  _____________immutable borrow occurs here
       | |
    78 | |         .lifetimes()
       | |____________________- a temporary with access to the immutable borrow is created here ...
    ...
    81 |           .unwrap_or_else(|| {
       |                           ^^ mutable borrow occurs here
    82 |               let lifetime: Lifetime = parse_quote!('a);
    83 |               generics.params.insert(
       |               --------------- second borrow occurs due to use of `generics.params` in closure
    ...
    88 |           });
       |             - ... and the immutable borrow might be used here, when that temporary is dropped and runs the destructor for type `impl Iterator<Item = &LifetimeParam>`
@dtolnay dtolnay merged commit 6cf2344 into master Aug 11, 2024
29 checks passed
@dtolnay dtolnay deleted the iterators branch August 11, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breaking change to Generics::lifetimes in v2.0.73
1 participant